package InterviewPractise.JAVAForSQL;

import InterviewPractise.JAVAForSQL.Entity.Table1Entity;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.format.datetime.DateFormatter;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 5/20/11
 * Time: 10:41 AM
 * To change this template use File | Settings | File Templates.
 */
public class MainClass {

    public static void main(String[] args) throws ParseException {
        DetachedCriteria criteria = DetachedCriteria.forClass(Table1Entity.class);
        SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-mm-dd");
        Date date = dateFormat.parse("2011-1-1");

        criteria.add(Restrictions.and((Criterion) Restrictions.eq("field3", date),Restrictions.or(Restrictions.le("field4",0),Restrictions.ge("field4",5))));

    }
}
